package cn.gov.pbc.exam.common;

public class QuestionConst {
	
	public static final String SELECTION_SEPARATOR = ",";
	
	public enum Type{
		JUDGE(0, "判断题"),
		SINGLE(1, "单选题"),
		MULTIPLE(2, "多选题");
		
		private int code;
		
		private String value;
		
		private Type(int code, String value){
			this.code = code;
			this.value = value;
		}
		public int getCode() {
			return code;
		}

		public String getValue() {
			return value;
		}
		public static Type codeOf(int code){
            for(Type type : values()){
                if(type.getCode() == code){
                    return type;
                }
            }
            return null;
        }
		public static Type searchByValue(String value){
			for(Type type : values()){
				if(type.getValue().equals(value)){
					return type;
				}
			}
			return null;
		}
	}
	
	public enum OptionStatus{
		RIGHT(0, "正确"),
		WRONG(1, "错误");
		
		private int code;
		
		private String value;
		
		private OptionStatus(int code, String value){
			this.code = code;
			this.value = value;
		}
		public int getCode() {
			return code;
		}

		public String getValue() {
			return value;
		}
		public static OptionStatus codeOf(int code){
            for(OptionStatus optionStatus : values()){
                if(optionStatus.getCode() == code){
                    return optionStatus;
                }
            }
            return null;
        }
		public static OptionStatus searchByValue(String value){
			for(OptionStatus optionStatus : values()){
				if(optionStatus.getValue().equals(value)){
					return optionStatus;
				}
			}
			return null;
		}
	}
	public enum CheckResult{
		RIGHT(0, "回答正确"),
		WRONG(1, "回答错误");
		
		private int code;
		
		private String value;
		
		private CheckResult(int code, String value){
			this.code = code;
			this.value = value;
		}
		public int getCode() {
			return code;
		}

		public String getValue() {
			return value;
		}
		public static CheckResult codeOf(int code){
            for(CheckResult checkResult : values()){
                if(checkResult.getCode() == code){
                    return checkResult;
                }
            }
            return null;
        }
	}
}
